var GameBase = require('geoGameBase');
var UIResultDialog = require('geoUIResultDialog');

cc.Class({
    extends: GameBase,

    properties: {
        resultDialogPrefab:{
            default: null,
            type:cc.Prefab,
        },
        resultDialogContainer:{
            default:null,
            type:cc.Node,
        },
    },
    onLoad () {
        // 创建开始对话框
        var dlgNode = cc.instantiate(this.resultDialogPrefab);
        this.resultDialogContainer = this.resultDialogContainer || cc.director.getScene().getComponentInChildren(cc.Canvas).node;
        this.resultDialogContainer.addChild(dlgNode);
        // 获取对话框组件
        this._resultDlg = dlgNode.getComponent(UIResultDialog);
        // 设置回调
        this._resultDlg.setReplayButtonCallback(this.replay.bind(this));
    },
    start(){
        this.setScore(this.data.score);
    },
    /**
     * 重玩
     */
    replay(){
        cc.director.loadScene(this.data.replayScene);
    },
    /**
     * 设置分数
     * @param {int} score 
     */
    setScore(score, complete, step){
        this._resultDlg.setScore(score, complete, step);
    },

});
